import time

import requests, json
import datetime
###########################

actId = 2405280248609345  # 德黑兰常见的菠萝
actGoodId = 537184443
# 6月2日（周日）14:00法扎签售接龙
Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJ1aWQiOjE4NDYzNzAzOCwiZXhwIjoxNzE3ODkyOTkzfQ.NiQ0LiezdUlEHSFAdTL50x5u4tQC2_cjhpxN9GqHH4PPThsJOO1upbRhZNiuhChve5wA3kfSLzwt6qx6y3IYZg"
proxies = {"http": None, "https": None}
logname = "3bm_dhlcjdbl.log"
url = "https://apipro.qunjielong.com/order-cert/api/mina/user-order/query_order_personal_home_page?page=1&pageSize=10"
###########################
# while datetime.datetime.now() < datetime.datetime(2024, 6, 2, 12, 0, 0):
#     pass
#
# goodsUrl = "https://apipro.qunjielong.com/activity-biz/activity/detail/goods"
data = {
}
headers = {
    "Host": "apipro.qunjielong.com",
    "Connection": "keep-alive",
    "device-type": "10",
    "mini-route": "pro/pages/generate-order/generate-order",
    "Authorization": Authorization,
    "uid": "182893922",
    "companyId": "190",
    "scene-flow": "seq-detail,8f15647b333a5fcda597696b51e2dfe0",
    "client-version": "5.6.7",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a1b) XWEB/9129",
    "Content-Type": "application/json",
    "xweb_xhr": "1",
    "appid": "wx059cd327295ab444",
    "sceneCode": "1007",
    "version": "3.0.0",
    "Accept": "*/*",
    "Sec-Fetch-Site": "cross-site",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Dest": "empty",
    "Referer": "https://servicewechat.com/wx059cd327295ab444/1784/page-frame.html",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9"
}
res = requests.post(url, headers=headers, data=json.dumps(data), proxies=proxies)
print(res.text)
#
# place_all = "https://apipro.qunjielong.com/order-place/api/mina/order_place/place-all"
#
#
# def run(f_w):
#     try:
#         # data = {
#         #     "signUpOrderDTO": {
#         #         "userInfo": {},
#         #         "proOrderItemParamList": [{
#         #             "actGoodId": actGoodId,
#         #             "buyQuantity": 1
#         #         }],
#         #         "dlvAddrId": 0,
#         #         "proOrderDefExts": [],
#         #         "markInfoJson": {
#         #             "markInfoList": [{
#         #                 "type": "text",
#         #                 "content": [cdesc]
#         #             }]
#         #         },
#         #         "orderDefItemList": []
#         #     },
#         #     "actId": actId
#         # }
#
#         data = {
#             "signUpOrderDTO": {
#                 "userInfo": {},
#                 "proOrderItemParamList": [{
#                     "actGoodId": actGoodId,
#                     "buyQuantity": 1
#                 }],
#                 "dlvAddrId": 0,
#                 "proOrderDefExts": [],
#                 "markInfoJson": {},
#                 "orderDefItemList": []
#             },
#             "actId": actId
#         }
#         res = requests.post(place_all, headers=headers, data=json.dumps(data), proxies=proxies)
#         print(res.text)
#         f_w.write(json.dumps(res.json(), indent=4, ensure_ascii=False, sort_keys=True))
#         f_w.write("\n")
#         orderNo = res.json().get("data").get("orderNo")
#         query_order_pay_success_toast_list = "https://apipro.qunjielong.com/order-place/api/mina/order_place/query_order_pay_success_toast_list?actId={}&orderNo={}".format(
#             actId, orderNo)
#         res = requests.get(query_order_pay_success_toast_list, headers=headers, proxies=proxies)
#         print(res.text)
#         f_w.write(json.dumps(res.json(), indent=4, ensure_ascii=False, sort_keys=True))
#         f_w.write("\n")
#         if res.json().get("success"):
#             return True
#     except Exception as e:
#         print(e)
#         return False
#
#
# with open(logname, "w", encoding="utf-8") as f_w:
#     for i in range(10):
#         f_w.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") + "\n")
#         if run(f_w):
#             break
#         time.sleep(0.2)

